import 'package:hm_show_flutter/entity/company.dart';
import 'package:hm_show_flutter/entity/user.dart';

class LoginEntity {
	int errno;
	LoginData data;
	String errmsg;

	LoginEntity({this.errno, this.data, this.errmsg});

	LoginEntity.fromJson(Map<String, dynamic> json) {
		errno = json['errno'];
		data = json['data'] != null ? new LoginData.fromJson(json['data']) : null;
		errmsg = json['errmsg'];
	}

	Map<String, dynamic> toJson() {
		final Map<String, dynamic> data = new Map<String, dynamic>();
		data['errno'] = this.errno;
		if (this.data != null) {
      data['data'] = this.data.toJson();
    }
		data['errmsg'] = this.errmsg;
		return data;
	}
}

class LoginData {
	List<CompanyModel> companyList;
	int expire;
	String company;
	UserModel user;
	String token;

	LoginData({this.companyList, this.expire, this.company, this.user, this.token});

	LoginData.fromJson(Map<String, dynamic> json) {
		if (json['companyList'] != null) {
			companyList = new List<CompanyModel>();(json['companyList'] as List).forEach((v) { companyList.add(new CompanyModel.fromJson(v)); });
		}
		expire = json['expire'];
		company = json['company'];
		user = json['user'] != null ? new UserModel.fromJson(json['user']) : null;
		token = json['token'];
	}

	Map<String, dynamic> toJson() {
		final Map<String, dynamic> data = new Map<String, dynamic>();
		if (this.companyList != null) {
      data['companyList'] =  this.companyList.map((v) => v.toJson()).toList();
    }
		data['expire'] = this.expire;
		data['company'] = this.company;
		if (this.user != null) {
      data['user'] = this.user.toJson();
    }
		data['token'] = this.token;
		return data;
	}
}


